/* $Id: FullTextTypeBeanInfo.java,v 1.2 2003/08/02 19:20:02 survey Exp $
 * 
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */


package org.medbeans.modules.search.types;


import java.awt.Image;
import java.beans.BeanInfo;
import java.beans.BeanDescriptor;
import java.beans.EventSetDescriptor;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyChangeListener;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;
//import javax.swing.ImageIcon;

import org.openide.TopManager;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openidex.search.SearchType;


/**
 * Bean info for <code>FullTextType</code> search type.
 *
 * @author Petr Kuzel
 */
public class FullTextTypeBeanInfo extends SimpleBeanInfo {

    /** Gets property descriptors. Overrides superclass method. */
    public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            PropertyDescriptor p1 = new PropertyDescriptor("matchString", FullTextType.class, "getMatchString", "setMatchString" ); // NOI18N
            p1.setDisplayName(NbBundle.getBundle(FullTextType.class).getString("TEXT_PROP_SUBSTRING") ); // NOI18N
            
            PropertyDescriptor p2 = new PropertyDescriptor("re", FullTextType.class, "getRe", "setRe" ); // NOI18N
            p2.setDisplayName(NbBundle.getBundle(FullTextType.class).getString("TEXT_PROP_RE") ); // NOI18N
            
            return new PropertyDescriptor[] {p1, p2};
        } catch(IntrospectionException ie) {
            TopManager.getDefault().getErrorManager().notify(ie);
            
            return null;
        }
    }

    /** Gets event set descriptors. Overrides superclass method. */
    public EventSetDescriptor[] getEventSetDescriptors() {
        try {
            return new EventSetDescriptor[] {
                new EventSetDescriptor(
                    FullTextType.class,
                    "propertyChangeListener", // NOI18N
                    PropertyChangeListener.class,
                    new String[0],
                    "addPropertyChangeListener", // NOI18N
                    "removePropertyChangeListener") // NOI18N
            };
        } catch( IntrospectionException ie) {
            TopManager.getDefault().getErrorManager().notify(ie);
            
            return null;
        }
    }

    /** Gets icon. Overrides superclass method. */
    public Image getIcon (int type) {
        if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
            return Utilities.loadImage("org/netbeans/modules/search/res/find.gif"); // NOI18N
        } else {
            return null;
        }
    }

    /** Gets bean descriptor. Overrides superclass method. */
    public BeanDescriptor getBeanDescriptor(){
        BeanDescriptor descr = new BeanDescriptor(FullTextType.class, FullTextCustomizer.class);
        descr.setDisplayName(NbBundle.getBundle(FullTextType.class).getString("TEXT_FULLTEXT_CRITERION")); // NOI18N
        
        return descr;
    }

    /** Gets additional bean infos. Overrides superclass method. */
    public BeanInfo[] getAdditionalBeanInfo () {
        try {
            return new BeanInfo[] { Introspector.getBeanInfo(SearchType.class) };
        } catch (IntrospectionException ie) {
            TopManager.getDefault().getErrorManager().notify(ie);
            
            return null;
        }
    }

}
